/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.h;

import android.content.Context;
import android.os.Build.VERSION;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.common.e.a;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.login.plugin.d;
import com.qihoo.gamecenter.sdk.login.plugin.d.a;
import com.qihoo.stat.QHStatDo;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONObject;

public class k {
    public static String a(Context paramContext) {
        Random localRandom = new Random(System.currentTimeMillis());
        StringBuilder localStringBuilder = new StringBuilder();
        for (int i = 0; i < 10; ++i)
            localStringBuilder.append(Math.abs(localRandom.nextInt()) % 10);
        String str = localStringBuilder.toString();
        e.a("RegisterUtils", new Object[] { "rcode=" + str });
        return str;
    }

    public static String b(Context paramContext) {
        return ((TelephonyManager) paramContext.getSystemService("phone")).getDeviceId();
    }

    public static String c(Context paramContext) {
        return Build.VERSION.RELEASE;
    }

    public static boolean a(String paramString) {
        return Pattern.matches("^([a-z0-9A-Z_-])+(\\.[a-z0-9A-Z_-]+)*@([a-z0-9A-Z_-])+((\\.\\w{2,3}){1,3})$",
                paramString);
    }

    public static boolean b(String paramString) {
        return Pattern.matches("[a-z0-9A-Z_]+", paramString);
    }

    public static boolean c(String paramString) {
        int i = 0;
        char[] arrayOfChar = paramString.toCharArray();
        int j = Character.getNumericValue(arrayOfChar[0]);
        int k = Character.getNumericValue(arrayOfChar[1]);
        if ((j >= 0) && (k >= 0)) {
            i = 1;
            int l = arrayOfChar.length;
            int i1 = j - k;
            for (int i4 = 1; i4 < l - 1; ++i4) {
                int i3 = Character.getNumericValue(arrayOfChar[(i4 + 1)]);
                int i2 = k - i3;
                if (i2 != i1) {
                    i = 0;
                    break;
                }
                k = i3;
            }
        }
        if (i != 0)
            return true;
        return ("asdasd,asdfgh,asdfghjkl,Iloveyou,qwerty,Password,Passwd,Woaini,Wodemima,Woaiwojia,zxcvbn,tamade,nimade,123abc,0123456, 0123456789,100200,102030,121212,111222,115415,123000,123123,123789,12301230,123321,123456,1234560,123465,1234567,12345678,123456789,1234567890,123123123,1314520,1314521,147258369,147852369,159357,168168,201314,211314,321321,456456,4655321,521521,5201314,520520,741852,741852963,7758258,7758521,654321,852963,987654,963852741,000000,11111111111111,112233,666666,888888,abcdef,abcabc,abc123,a1b2c3,aaa111,123qwe,qweasd,admin,password,p@ssword,passwd,iloveyou,1qaz2wsx,qwertyuiop,qq123456,1q2w3e4r,123456abc,abc123456,qazwsxedc,1q2w3e4r5t"
                .indexOf(paramString) >= 0);
    }

    public static String d(Context paramContext) {
        String str1 = b(paramContext);
        String str2 = (str1 == null) ? "none imei" : str1;
        String str3 = c(paramContext);
        try {
            return URLEncoder.encode(f.a(str2 + str3), "UTF-8").toLowerCase();
        } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
            e.b("RegisterUtils", "", localUnsupportedEncodingException);
        }
        return str2 + str3;
    }

    public static boolean a(char paramChar) {
        int i = paramChar;
        return ((i >= 19968) && (i <= 171941));
    }

    public static boolean d(String paramString) {
        if ((null == paramString) || ("".equals(paramString.trim())))
            return false;
        for (int i = 0; i < paramString.length(); ++i)
            if (a(paramString.charAt(i)))
                return true;
        return false;
    }

    public static String a(Context paramContext, String paramString1, String paramString2, String paramString3,
            String paramString4, String paramString5) {
        String str1 = "";
        try {
            str1 = str1 + URLEncoder.encode(f.a(paramString2), "UTF-8").toLowerCase();
        } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
            e.b("RegisterUtils", "", localUnsupportedEncodingException);
            return null;
        }
        HashMap localHashMap = new HashMap();
        localHashMap.put("account", paramString1);
        localHashMap.put("type", (a(paramString1)) ? "1" : "4");
        localHashMap.put("password", str1);
        localHashMap.put("pwdmethod", "1");
        localHashMap.put("fields", "qid,username,loginemail");
        localHashMap.put("head_type", "m");
        localHashMap.put("mid", d(paramContext));
        localHashMap.put("sc", paramString4);
        localHashMap.put("uc", paramString3);
        localHashMap.put("method", "CommonAccount.register");
        e.a("RegisterUtils", new Object[] { "getRegisterUrl params = " + localHashMap });
        String str2 = a.a(localHashMap, s.q(paramContext));
        e.a("RegisterUtils", new Object[] { "getRegisterUrl url = " + str2 });
        return str2;
    }

    public static int a(Editable paramEditable) {
        int i = -1;
        if (!(TextUtils.isEmpty(paramEditable))) {
            int j = 128;
            char[] arrayOfChar = paramEditable.toString().toCharArray();
            for (int k = 0; k < arrayOfChar.length; ++k) {
                if (arrayOfChar[k] / j == 0)
                    continue;
                i = k;
                break;
            }
        }
        return i;
    }

    public static Editable b(Editable paramEditable) {
        Editable localEditable = null;
        int i = a(paramEditable);
        if (i != -1)
            localEditable = paramEditable.delete(i, paramEditable.length());
        return localEditable;
    }

    public static String a(Context paramContext, String paramString1, String paramString2, String paramString3,
            String paramString4) {
        String str1 = "";
        String str2 = "";
        try {
            str1 = str1 + URLEncoder.encode(f.a(paramString2), "UTF-8").toLowerCase();
            str2 = str2 + URLEncoder.encode(f.a(paramString3), "UTF-8").toLowerCase();
        } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
            e.b("RegisterUtils", "", localUnsupportedEncodingException);
            return null;
        }
        HashMap localHashMap = new HashMap();
        localHashMap.put("account", paramString1);
        localHashMap.put("type", "2");
        localHashMap.put("oldpwd", str1);
        localHashMap.put("newpwd", str2);
        localHashMap.put("method", "CommonAccount.modifyAccountPwd");
        e.a("RegisterUtils", new Object[] { "getModifyPwdUrl params = " + localHashMap });
        String str3 = a.a(localHashMap, s.q(paramContext));
        e.a("RegisterUtils", new Object[] { "getModifyPwdUrl url = " + str3 });
        return str3;
    }

    public static String b(Context paramContext, String paramString1, String paramString2, String paramString3,
            String paramString4) {
        String str1 = "";
        if (!(TextUtils.isEmpty(paramString2)))
            try {
                str1 = str1 + URLEncoder.encode(f.a(paramString2), "UTF-8").toLowerCase();
            } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
                e.b("RegisterUtils", "", localUnsupportedEncodingException);
                return null;
            }
        HashMap localHashMap = new HashMap();
        localHashMap.put("account", paramString1);
        localHashMap.put("type", "2");
        if (TextUtils.isEmpty(str1))
            localHashMap.put("is_rand_pass", "1");
        else
            localHashMap.put("password", str1);
        localHashMap.put("pwdmethod", "1");
        localHashMap.put("fields", "qid,username,loginemail");
        localHashMap.put("head_type", "m");
        localHashMap.put("mid", d(paramContext));
        localHashMap.put("smscode", paramString3);
        localHashMap.put("method", "CommonAccount.register");
        e.a("RegisterUtils", new Object[] { "getRegisterWithSmsCodeUrl params = " + localHashMap });
        String str2 = a.a(localHashMap, s.q(paramContext));
        e.a("RegisterUtils", new Object[] { "getRegisterWithSmsCodeUrl url = " + str2 });
        return str2;
    }

    public static String a(Context paramContext, String paramString1, String paramString2, String paramString3) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("randCode", paramString1);
        localHashMap.put("mid", d(paramContext));
        if (!(TextUtils.isEmpty(paramString2)))
            localHashMap.put("deviceId", paramString2);
        localHashMap.put("isnop", "1");
        localHashMap.put("method", "CommonAccount.checkMobileSmsReg");
        e.a("RegisterUtils", new Object[] { "getUpLineRegSmsCheckUrl params = " + localHashMap });
        String str = a.a(localHashMap, s.q(paramContext));
        e.a("RegisterUtils", new Object[] { "getUpLineRegSmsCheckUrl url = " + str });
        return str;
    }

    public static boolean e(String paramString) {
        Pattern localPattern = Pattern.compile("[\\u4e00-\\u9fa5]+");
        Matcher localMatcher = localPattern.matcher(paramString);
        return localMatcher.find();
    }

    public static void a(String paramString1, String paramString2) {
        int i = -1;
        String str = "";
        try {
            JSONObject localJSONObject = new JSONObject(paramString1);
            i = localJSONObject.optInt("errno", -1);
            str = localJSONObject.optString("errmsg", "");
            str = a(i, str);
        } catch (Exception localException) {
            e.b("RegisterUtils", "statOnRegisterEnd Error!", localException);
        }
        HashMap localHashMap = new HashMap();
        if (i != 0) {
            localHashMap.put("login_error_no", "" + i);
            localHashMap.put("login_error_msg", str);
        }
        localHashMap.put("login_reg_mode", paramString2);
        QHStatDo.event((0 == i) ? "360sdk_login_reg_success" : "360sdk_login_reg_failed", localHashMap);
    }

    public static String a(int paramInt, String paramString) {
        if (213 == paramInt)
            return d.a(d.a.O);
        if (215 == paramInt)
            return d.a(d.a.P);
        if (225 == paramInt)
            return d.a(d.a.Q);
        if (231 == paramInt)
            return d.a(d.a.T);
        if (232 == paramInt)
            return d.a(d.a.Y);
        if (1030 == paramInt)
            return d.a(d.a.ac);
        if (1033 == paramInt)
            return d.a(d.a.ad);
        if (1034 == paramInt)
            return d.a(d.a.ae);
        if (1035 == paramInt)
            return d.a(d.a.af);
        if (1037 == paramInt)
            return d.a(d.a.ag);
        if (1060 == paramInt)
            return d.a(d.a.ai);
        if (1070 == paramInt)
            return d.a(d.a.an);
        if (1251 == paramInt)
            return d.a(d.a.ao);
        if (1252 == paramInt)
            return d.a(d.a.ap);
        if (5010 == paramInt)
            return d.a(d.a.aE);
        if (5011 == paramInt)
            return d.a(d.a.aF);
        return d.a(d.a.bb);
    }
}